export default {
	namespaced: true,

	state: () => ({
		token: uni.getStorageSync('token') ||
			'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwZXJtaXNzaW9uIjoiQURNSU4iLCJleHAiOjE2NjI2MzAwNTQsImlhdCI6MTY2MjAyNTI1NCwidXNlcklkIjoiMjU2In0.BRIF5ape0yCSdGLEZXYLEYjOguPBnANFAs3oWQubPtU',
		userInfo: JSON.parse(uni.getStorageSync('userinfo') || '{}')
	}),

	mutations: {
		updateUserInfo(state, userinfo) {
			state.userinfo = userinfo
			this.commit('m_user/saveUserInfoToStorage')
		},
		saveUserInfoToStorage(state) {
			uni.setStorageSync('userinfo', JSON.stringify(state.userinfo))
		},
		updateToken(state, token) {
			state.token = token
			this.commit('m_user/saveTokenToStorage')
		},
		saveTokenToStorage(state) {
			uni.setStorageSync('token', state.token)
		}
	},

	getter: {}
}
